using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;


namespace Business
{
    public enum ChucVuBUSResult
    {
        OK,
        MACVERROR,
        TENCVCERROR,
        DAOERROR
    }

    public class clsChucVuBUS
    {
        //Fields.
        private clsChucVuDAO chucVuDAO;

        //Constructors.
        public clsChucVuBUS()
        {
            this.chucVuDAO = new clsChucVuDAO();
        }

        #region Methods

        public ChucVuBUSResult KiemTraRong(clsChucVuDTO  obj)
        {
            if (obj.MaCV  == "")
                return ChucVuBUSResult.MACVERROR;
            if ((obj.TenCV  == ""))
                return ChucVuBUSResult.TENCVCERROR ;
            return ChucVuBUSResult.OK;
        }

        public int KiemTraMaCVDeXoa(clsChucVuDTO obj)
        {
            return this.chucVuDAO.KiemTraMaCVXoaDuocKhong(obj);
        }

        public DataTable DanhSachChucVu()
        {
            return this.chucVuDAO.SelectAll();
        }

        public ChucVuBUSResult ThemChucVu(clsChucVuDTO obj)
        {
            if (!this.chucVuDAO.Insert(obj))
                return ChucVuBUSResult.DAOERROR;
            return ChucVuBUSResult.OK;
        }
        public ChucVuBUSResult SuaChucVu(clsChucVuDTO obj)
        {
            if (!this.chucVuDAO.Update(obj))
                return ChucVuBUSResult.DAOERROR;
            return ChucVuBUSResult.OK;
        }

        public ChucVuBUSResult XoaChucVu(clsChucVuDTO obj)
        {
            if (!this.chucVuDAO.Delete(obj))
                return ChucVuBUSResult.DAOERROR;
            return ChucVuBUSResult.OK;
        }
        #endregion
    }
}
